package com.fottas.adware.factory;

import com.fottas.adware.core.*;

public class WxFactory {

    /**
     * 将一些初始化信息缓存在上下文中
     */
    private static Context context;

    public static void setOptions(WXConfig options) {
        context = new Context(options);
    }

    /**
     * 获取接口请求的 URL
     *
     * @param apiType {@link ApiType} 支付 API 接口枚举
     * @param domain  {@link Domain} 支付 API 接口域名枚举
     * @param isSandBox 是否是沙箱环境
     * @return {@link String} 返回完整的接口请求URL
     */
    public static String getReqUrl(ApiType apiType, Domain domain, boolean isSandBox) {
        if (domain == null) {
            domain = Domain.CHINA;
        }
        return domain.getType()
                .concat(isSandBox ? ApiType.SAND_BOX_NEW.getType() : "")
                .concat(apiType.getType());
    }

    public static class Payment {


        /**
         * 获取手机APP支付相关API Client
         *
         * @return 手机APP支付相关API Client
         */
        public static com.fottas.adware.payment.app.Client App() throws Exception {
            return new com.fottas.adware.payment.app.Client(new Client(context));
        }
    }
}
